import json
from django.http.response import HttpResponse, JsonResponse
import gitlab
from django.views import View

gitUrl = "http://127.0.0.1/"
gitToken = "sBqTQsp9zQTQuRWrYS1W"

gitLogin = gitlab.Gitlab(gitUrl, private_token=gitToken)


class listProject(View):
    @staticmethod
    def get(request):
        # 获取gitlab所有project的信息
        gitlabListProject = gitLogin.projects.list(all=True)

        allProject = []
        for i in gitlabListProject:
            allProject.append(i.attributes)

        return JsonResponse(allProject, safe=False)
